package com.moore.Servlet;

import com.alibaba.fastjson2.JSON;
import com.moore.net.HttpRequest;
import com.moore.net.HttpResponse;
import com.moore.net.HttpServlet;
import com.moore.utils.UserUtils;

import java.util.List;

public class PasswordServlet extends HttpServlet {
    @Override
    public byte[] doGet(HttpRequest request, HttpResponse response) {
        String responseData = "";
        String type = request.getParams().get("type");
        String id = request.getParams().get("id");
        if (type.equals("get")){
            List<String> list = UserUtils.getPassWord(id);
            responseData = JSON.toJSONString(list);
        } else if (type.equals("update")) {
            String password = request.getParams().get("password");
            responseData = UserUtils.update("password",password,id);
        }
        return responseData.getBytes();
    }
}
